<?php
class TxtViewer extends ContentFile
{
	public function readContent( $oResponse, $sAbsolutePath )
	{
		$size = filesize( $sAbsolutePath );
		$in = fopen( $sAbsolutePath,'r');
		$data = fread( $in, $size );
		fclose( $in );
		
		$data = $this->txt2html( $data );
		
		$oResponse->data( $data );
		$oResponse->requestExecuted();
	}
	
	private function txt2html( $sTxt )
	{
		$sTxt = htmlspecialchars( $sTxt );
		$sTxt = str_replace( "\n", "<br/>", $sTxt );
		$sTxt = str_replace( "\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $sTxt );
		
		return $sTxt;
	}
} 
?>